/*
 * @Description: 动态分配内存
 *   C goes beyond this. You can allocate more memory as a program runs. The main tool is the malloc() function, which takes one argument: the number of bytes of memory you want.
 *   Then malloc() finds a suitable block of free memory. The memory is anonymous; that is, malloc() allocates memory but it doesn’t assign a name to it. However, it does return the address of the first byte of that block.
 *   If malloc() fails to find the required space, it returns the null pointer
 * @Author: marshal marshalby2@gmail.com
 * @Date: 2022-06-21 20:23:30
 * @LastEditors: marshal
 * @LastEditTime: 2022-06-23 14:27:05
 */
#include <stdio.h>
#include <stdlib.h>

#define LEN 10

int main(int argc, char const *argv[])
{

    // This code requests space for 30 type int values and sets pti to point to the location.
    int *pti;
    pti = (int *)malloc(LEN * sizeof(int));
    pti[0] = 100;
    printf("pti[0] = %d\n", pti[0]); // 100
    printf("pti[1] = %d\n", pti[1]); // 0
    free(pti);
    return 0;
}
